﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList lings = new SortedList();
            lings.Add(1,"黄志浩");
            lings.Add(2,"黄燕鸿");
            lings.Add(3,"江鑫宇");
            lings.Add(4,"景衡光");
            lings.Add(5,"阮灿彬");

            Console.WriteLine("全部学生如下：");
            foreach (DictionaryEntry aa in lings)
            {
                 int key=(int)aa.Key;
                string name = aa.Value.ToString();
                Console.WriteLine("学生学号：{0}姓名：{1}",key,name);
            }

            Console.WriteLine();
            Console.WriteLine();


            Console.WriteLine("请输入学生学号：");
            int id = int.Parse(Console.ReadLine());
            var flag = lings.ContainsKey(id);
            if (flag)
            {
                string name = lings[id].ToString();
                Console.WriteLine("你要找的人是：{0}", name);
            }
            else
            {
                Console.WriteLine("查无此人");
            }
        }
    }
}
